[IA64] vti save-restore: ia64 hvm builder clean up with respect to hvm params.
authorAlex Williamson <alex.williamson@hp.com>
Wed, 7 Nov 2007 17:34:09 +0000 (10:34 -0700)
committerAlex Williamson <alex.williamson@hp.com>
Wed, 7 Nov 2007 17:34:09 +0000 (10:34 -0700)
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
tools/libxc/ia64/xc_ia64_hvm_build.c
tools/libxc/ia64/xc_ia64_linux_restore.c
tools/libxc/ia64/xc_ia64_linux_save.c

index 3e14eaf7355fe90a7ba4c03a66c872aef188c325..5fc0d58fa9d9833a7f7c9ec04d65cc002f56c6e8 100644 (file)
@@ -893,9 +893,6 @@ setup_guest(int xc_handle, uint32_t dom, unsigned long memsize,
             char *image, unsigned long image_size)
 {
     xen_pfn_t *pfn_list;
-    shared_iopage_t *sp;
-    void *ioreq_buffer_page;
-    void *pio_buffer_page;
     unsigned long dom_memsize = memsize << 20;
     unsigned long nr_pages = memsize << (20 - PAGE_SHIFT);
     unsigned long vcpus;
@@ -905,6 +902,16 @@ setup_guest(int xc_handle, uint32_t dom, unsigned long memsize,
     unsigned long nvram_start = NVRAM_START, nvram_fd = 0; 
     int rc;
     long i;
+    const struct hvm_special_page {
+        int             param;
+        xen_pfn_t       pfn;
+    } special_pages[] = {
+        // pfn-sorted array
+        { HVM_PARAM_IOREQ_PFN,          IO_PAGE_START         >> PAGE_SHIFT},
+        { HVM_PARAM_STORE_PFN,          STORE_PAGE_START      >> PAGE_SHIFT},
+        { HVM_PARAM_BUFIOREQ_PFN,       BUFFER_IO_PAGE_START  >> PAGE_SHIFT}, 
+        { HVM_PARAM_BUFPIOREQ_PFN,      BUFFER_PIO_PAGE_START >> PAGE_SHIFT},
+    };
     DECLARE_DOMCTL;
 
 
@@ -957,18 +964,12 @@ setup_guest(int xc_handle, uint32_t dom, unsigned long memsize,
         goto error_out;
     }
 
-    nr_special_pages = 0;
-    pfn_list[nr_special_pages] = IO_PAGE_START >> PAGE_SHIFT;
-    nr_special_pages++;
-    pfn_list[nr_special_pages] = STORE_PAGE_START >> PAGE_SHIFT;
-    nr_special_pages++;
-    pfn_list[nr_special_pages] = BUFFER_IO_PAGE_START >> PAGE_SHIFT;
-    nr_special_pages++;
-    pfn_list[nr_special_pages] = BUFFER_PIO_PAGE_START >> PAGE_SHIFT;
+    for (i = 0; i < sizeof(special_pages) / sizeof(special_pages[0]); i++)
+        pfn_list[i] = special_pages[i].pfn;
 
-    memmap_info_pfn = pfn_list[nr_special_pages] + 1;
+    nr_special_pages = i;
+    memmap_info_pfn = pfn_list[nr_special_pages - 1] + 1;
     memmap_info_num_pages = 1;
-    nr_special_pages++;
     pfn_list[nr_special_pages] = memmap_info_pfn;
     nr_special_pages++;
 
@@ -1033,28 +1034,14 @@ setup_guest(int xc_handle, uint32_t dom, unsigned long memsize,
         goto error_out;
     }
 
-    xc_set_hvm_param(xc_handle, dom, HVM_PARAM_STORE_PFN, pfn_list[1]);
-
-    // Retrieve special pages like io, xenstore, etc. 
-    sp = (shared_iopage_t *)xc_map_foreign_range(xc_handle, dom, PAGE_SIZE,
-                                                 PROT_READ | PROT_WRITE,
-                                                 pfn_list[0]);
-    if (sp == 0)
-        goto error_out;
-
-    memset(sp, 0, PAGE_SIZE);
-    munmap(sp, PAGE_SIZE);
-    ioreq_buffer_page = xc_map_foreign_range(xc_handle, dom, PAGE_SIZE,
-                                             PROT_READ | PROT_WRITE,
-                                             pfn_list[2]); 
-    memset(ioreq_buffer_page,0,PAGE_SIZE);
-    munmap(ioreq_buffer_page, PAGE_SIZE);
+    // zero clear all special pages
+    for (i = 0; i < sizeof(special_pages) / sizeof(special_pages[0]); i++) {
+        xc_set_hvm_param(xc_handle, dom,
+                         special_pages[i].param, special_pages[i].pfn);
+        if (xc_clear_domain_page(xc_handle, dom, special_pages[i].pfn))
+            goto error_out;
+    }
 
-    pio_buffer_page = xc_map_foreign_range(xc_handle, dom, PAGE_SIZE,
-                                           PROT_READ | PROT_WRITE,
-                                           pfn_list[3]);
-    memset(pio_buffer_page,0,PAGE_SIZE);
-    munmap(pio_buffer_page, PAGE_SIZE);
     free(pfn_list);
     return 0;
 
index 5336b5bd513a802fe7993c4e5a5d3ca2aa8f8c86..16d1896070950a911ab5fac091ae2e22c6d2ebfc 100644 (file)
@@ -285,9 +285,10 @@ xc_ia64_hvm_recv_context(int xc_handle, int io_fd, uint32_t dom,
 
     /* HVM: magic frames for ioreqs and xenstore comms */
     const int hvm_params[] = {
+        HVM_PARAM_STORE_PFN,
         HVM_PARAM_IOREQ_PFN,
         HVM_PARAM_BUFIOREQ_PFN,
-        HVM_PARAM_STORE_PFN,
+        HVM_PARAM_BUFPIOREQ_PFN,
     };
     const int NR_PARAMS = sizeof(hvm_params) / sizeof(hvm_params[0]);
     /* ioreq_pfn, bufioreq_pfn, store_pfn */
@@ -368,7 +369,7 @@ xc_ia64_hvm_recv_context(int xc_handle, int io_fd, uint32_t dom,
         ERROR("error setting HVM params: %i", rc);
         goto out;
     }
-    *store_mfn = magic_pfns[2];
+    *store_mfn = magic_pfns[0];
 
     /* Read HVM context */
     if (!read_exact(io_fd, &rec_size, sizeof(rec_size))) {
index 046f7c4cdde5918c251c1654543dc8a6420d1b78..c9a18fd4bbc261427e760dc8ee224f344d6f0a78 100644 (file)
@@ -285,9 +285,10 @@ xc_ia64_hvm_send_context(int xc_handle, int io_fd, uint32_t dom,
 
     /* HVM: magic frames for ioreqs and xenstore comms */
     const int hvm_params[] = {
+        HVM_PARAM_STORE_PFN,
         HVM_PARAM_IOREQ_PFN,
         HVM_PARAM_BUFIOREQ_PFN,
-        HVM_PARAM_STORE_PFN,
+        HVM_PARAM_BUFPIOREQ_PFN,
     };
     const int NR_PARAMS = sizeof(hvm_params) / sizeof(hvm_params[0]);
     /* ioreq_pfn, bufioreq_pfn, store_pfn */